﻿<div class="h-24 b-d-b-c-ccc g-d-w l-h-24">
    <span class="p-l-8 f-w-b">{{if isset($item)}}Category edit{{else}}Add new category{{/if}}</span>
</div>
<div class="grid_8 p-t-20 p-l-20 ">
    <input 
            type="hidden" 
            value="{{$item->cate_title}}" 
            id="cate_title_curent" name="cate_title_curent"
            />
    <form id="cate_frm" name="cate_frm" action="{{"excution"|base_url}}" method="POST" 
		  onsubmit="return false;" 
		  target="integration_asynchronous" autocomplete="off" 
		  >
		<!--      title      -->
		<div class="p-r p-b-12">
			<p>Title</p>
			<div class="p-r">
				<input 
					type="text" onblur="AliasTo('#cate_title','#cate_alias')"
					class="w-320 b-g-c-w validate[required]" 
					value="{{$item->cate_title}}" 
					minlength="10"
					maxlength="120" 
					id="cate_title" name="cate_title"
					/>
				
				<input 
					type="hidden" 
					value="{{$item->cate_id}}" 
					id="cate_id" name="cate_id"
					/>
			</div>
		</div>
		<div class="clear"></div>
		<!--      alias      -->
		<div class="p-r p-b-12">
			<p><label class="d-p-b w-i" for="cate_alias">Alias</label></p>
			<div class="p-r">
				<input 
					type="text" 
					class="w-i b-g-c-w validate[required,custom[alias]]" 
					value="{{$item->cate_alias}}" 
					minlength="10"
					maxlength="120" 
					id="cate_alias" name="cate_alias"
					/>
			</div>
		</div>
		<div class="clear"></div>
		<!--      parent      -->
		<div class="p-r p-b-12">
			<p>Parent</p>
			<div class="p-r b-g-c-w w-320">
				{{function catitem level=0}}
					{{foreach $data as $cat}}
						{{if isset($item)}}
							{{if $cat->cate_parent==$level and !$item->cate_id|in_array:$cat->parents and $item->cate_id!=$cat->cate_id}}
								<option {{if $item->cate_parent==$cat->cate_id}}selected="1"{{/if}} 
									value="{{$cat->cate_id}}">
									{{$cat->path}}
								</option>
								{{catitem data=$data level=$cat->cate_id}}
							{{else if $cat->cate_parent==$level and ( $item->cate_id|in_array:$cat->parents or $item->cate_id==$cat->cate_id )}}
								<option disabled="disabled" value="{{$cat->cate_id}}">
									{{$cat->path}}
								</option>
								{{catitem data=$data level=$cat->cate_id}}
							{{/if}}
						{{else}}
							{{if $cat->cate_parent==$level}}
								<option value="{{$cat->cate_id}}">
									{{$cat->path}}
								</option>
								{{catitem data=$data level=$cat->cate_id}}
							{{/if}}
						{{/if}}
					{{/foreach}}
				{{/function}}
				<select id="cate_parent" class="w-320 p-a t-0 l-0" name="cate_parent">
					<option value="0">Root</option>
					{{catitem data=$categories level=0}}
				</select>
			</div>
			<p class="erc"></p>
		</div>
		<div class="clear"></div>
		<div class="p-r p-b-12 f-l">
			<div class="f-l" style="width: 79px">
				<!--      birth      -->
				<div class="p-r-2">
					<div class="p-r">
						<p><label class="d-p-b w-i" for="cate_position">Position</label></p>
						<input 
							type="text" data-putto="#gr-err-1" 
							class="w-i b-g-c-w validate[min[0],max[99]]" 
							value="{{$item->cate_position}}" 
							minlength="7" min="0" max="99"
							maxlength="20" 
							id="cate_position" name="cate_position"
							/>
					</div>
				</div>
			</div>
			<div class="f-l" style="width: 81px">
				<!--      birth      -->
				<div class="p-l-2 p-r-2">
					<div class="p-r">
						<p><label class="d-p-b w-i" for="cate_status">Status</label></p>
						<div class="p-r">
							<select id="cate_status" name="cate_status" class="w-i">
								<option {{if $item->cate_status=='true'}}selected="1"{{/if}} value="true">Public</option>
								<option {{if $item->cate_status=='false'}}selected="1"{{/if}} value="false">Private</option>
							</select>
						</div>
					</div>
				</div>
			</div>
			<div class="f-l" style="width: 160px">
				<!--      year      -->
				<div class="p-l-2">
					<div class="p-r">
						<p><label class="d-p-b w-i" for="cate_type">Type</label></p>
						<div class="p-r">
							<select id="cate_type" name="cate_type" class="w-i">
								{{foreach $types as $key=>$value}}
								<option {{if $item->cate_type==$key}}selected="1"{{/if}} value="{{$key}}">{{$value}}</option>
								{{/foreach}}
							</select>
						</div>
					</div>
				</div>
			</div>
			<div class="clear"></div>
			<p id="gr-err-1" class="erb"></p>
		</div>
		<div class="clear"></div>
		<div class="p-r">
			<div id="step-3-back" onclick="CloseDialogMessage($('#reg-box-step-3'))" class="b-t-c g-d-w f-l m-r-8">Cancel</div>
			<div id="step-3-next" onclick="cate_save()" class="b-t-c g-d-w f-r">Save</div>
			<div class="clear"></div>
		</div>
	</form>
	<div class="clear"></div>
</div>
<div class="clear"></div>
<div class="clear"></div>